#pragma once

#include "iostream"
#include "vector"
#include "algorithm"
#include "queue"

using namespace std;

/*HJJ QQ479287006
 *6 做的时间长 效率低
 * */

vector<vector<int>> merge(vector<vector<int>> &intervals) {
    vector<vector<int>> ret;
    sort(intervals.begin(), intervals.end());

    ret.push_back({intervals[0][0], intervals[0][1]});


    for (int i = 1; i < intervals.size(); ++i) {

        if (ret.back()[1] >= intervals[i][0] && ret.back()[1] < intervals[i][1]) {
            ret.back()[1] = intervals[i][1];
        } else if (ret.back()[1] < intervals[i][0]) {
            ret.push_back({intervals[i][0], intervals[i][1]});
        }

    }

    return ret;
}